load("//bazel:skia_rules.bzl", "skia_cc_library", "split_srcs_and_hdrs")

package(
    default_applicable_licenses = ["//:license"],
)

licenses(["notice"])

GRAPHITE_FILES = [
    "AtlasProvider.cpp",
    "AtlasProvider.h",
    "Attribute.h",
    "BackendSemaphore.cpp",
    "BackendSemaphorePriv.h",
    "BackendTexture.cpp",
    "BackendTexturePriv.h",
    "Buffer.cpp",
    "Buffer.h",
    "BufferManager.cpp",
    "BufferManager.h",
    "BuiltInCodeSnippetID.h",
    "Caps.cpp",
    "Caps.h",
    "ClientMappedBufferManager.cpp",
    "ClientMappedBufferManager.h",
    "ClipAtlasManager.cpp",
    "ClipAtlasManager.h",
    "ClipStack.cpp",
    "ClipStack.h",
    "CommandBuffer.cpp",
    "CommandBuffer.h",
    "CommandTypes.h",
    "ComputePathAtlas.cpp",
    "ComputePathAtlas.h",
    "ComputePipeline.cpp",
    "ComputePipeline.h",
    "ComputePipelineDesc.h",
    "ComputeTypes.h",
    "Context.cpp",
    "ContextOptionsPriv.h",
    "ContextPriv.h",
    "ContextUtils.cpp",
    "ContextUtils.h",
    "DescriptorData.h",
    "Device.cpp",
    "Device.h",
    "DrawAtlas.cpp",
    "DrawAtlas.h",
    "DrawCommands.h",
    "DrawContext.cpp",
    "DrawContext.h",
    "DrawList.cpp",
    "DrawList.h",
    "DrawOrder.h",
    "DrawParams.h",
    "DrawPass.cpp",
    "DrawPass.h",
    "DrawTypes.h",
    "DrawWriter.cpp",
    "DrawWriter.h",
    "GlobalCache.cpp",
    "GlobalCache.h",
    "GpuWorkSubmission.cpp",
    "GpuWorkSubmission.h",
    "GraphicsPipeline.cpp",
    "GraphicsPipeline.h",
    "GraphicsPipelineDesc.h",
    "GraphiteResourceKey.cpp",
    "GraphiteResourceKey.h",
    "ImageFactories.cpp",
    "Image_Base_Graphite.cpp",
    "Image_Base_Graphite.h",
    "Image_Graphite.cpp",
    "Image_Graphite.h",
    "Image_YUVA_Graphite.cpp",
    "Image_YUVA_Graphite.h",
    "InternalDrawTypeFlags.h",
    "KeyContext.cpp",
    "KeyContext.h",
    "KeyHelpers.cpp",
    "KeyHelpers.h",
    "Log.h",
    "PaintParams.cpp",
    "PaintParams.h",
    "PaintParamsKey.cpp",
    "PaintParamsKey.h",
    "PathAtlas.cpp",
    "PathAtlas.h",
    "PipelineData.h",
    "ProxyCache.cpp",
    "ProxyCache.h",
    "QueueManager.cpp",
    "QueueManager.h",
    "RasterPathAtlas.cpp",
    "RasterPathAtlas.h",
    "RasterPathUtils.cpp",
    "RasterPathUtils.h",
    "ReadSwizzle.h",
    "Recorder.cpp",
    "RecorderPriv.h",
    "Recording.cpp",
    "RecordingPriv.h",
    "RenderPassDesc.cpp",
    "RenderPassDesc.h",
    "Renderer.cpp",
    "Renderer.h",
    "RendererProvider.cpp",
    "RendererProvider.h",
    "Resource.cpp",
    "Resource.h",
    "ResourceCache.cpp",
    "ResourceCache.h",
    "ResourceProvider.cpp",
    "ResourceProvider.h",
    "ResourceTypes.h",
    "RuntimeEffectDictionary.cpp",
    "RuntimeEffectDictionary.h",
    "Sampler.cpp",
    "Sampler.h",
    "ScratchResourceManager.cpp",
    "ScratchResourceManager.h",
    "ShaderCodeDictionary.cpp",
    "ShaderCodeDictionary.h",
    "ShaderInfo.cpp",
    "ShaderInfo.h",
    "SharedContext.cpp",
    "SharedContext.h",
    "SpecialImage_Graphite.cpp",
    "SpecialImage_Graphite.h",
    "Surface_Graphite.cpp",
    "Surface_Graphite.h",
    "Texture.cpp",
    "Texture.h",
    "TextureFormat.cpp",
    "TextureFormat.h",
    "TextureInfo.cpp",
    "TextureInfoPriv.h",
    "TextureProxy.cpp",
    "TextureProxy.h",
    "TextureProxyView.h",
    "TextureUtils.cpp",
    "TextureUtils.h",
    "PrecompileContext.cpp",
    "PrecompileContextPriv.h",
    "Uniform.h",
    "UniformManager.cpp",
    "UniformManager.h",
    "UniquePaintParamsID.h",
    "UploadBufferManager.cpp",
    "UploadBufferManager.h",
    "YUVABackendTextures.cpp",
]

split_srcs_and_hdrs(
    name = "_graphite",
    files = GRAPHITE_FILES,
)

PRECOMPILE_FILES = [
    "FactoryFunctions.cpp",
    "FactoryFunctions.h",
    "PrecompileInternal.h",
    "PublicPrecompile.cpp",
    "SerializationUtils.cpp",
    "SerializationUtils.h",
]

split_srcs_and_hdrs(
    name = "precompile",
    files = PRECOMPILE_FILES,
)

skia_cc_library(
    name = "graphite",
    srcs = [
        ":_graphite_srcs",
        "//src/gpu/graphite/compute:compute_srcs",
        "//src/gpu/graphite/geom:geom_srcs",
        "//src/gpu/graphite/render:render_srcs",
        "//src/gpu/graphite/task:task_srcs",
        "//src/gpu/graphite/text:text_srcs",
        "//src/sksl:sksl_graphite_modules_hdrs",
        "//src/sksl:sksl_graphite_modules_srcs",
        "//src/text/gpu:gpu_hdrs",
        "//src/text/gpu:gpu_srcs",
    ],
    hdrs = [
        ":_graphite_hdrs",
        "//include/gpu:shared_gpu_hdrs",
        "//include/gpu/graphite:public_hdrs",
        "//src/gpu/graphite/compute:compute_hdrs",
        "//src/gpu/graphite/geom:geom_hdrs",
        "//src/gpu/graphite/render:render_hdrs",
        "//src/gpu/graphite/task:task_hdrs",
        "//src/gpu/graphite/text:text_hdrs",
    ],
    defines = [
        "SK_GRAPHITE",
    ],
    visibility = [
        "//src/gpu/graphite/mtl:__pkg__",
        "//src/gpu/graphite/vk:__pkg__",
    ],
    deps = [
        "//:core",
        "//src/base",
        "//src/core:core_priv",
        "//src/gpu",
        "//src/sksl/codegen:gpu",
    ],
)

skia_cc_library(
    name = "graphite_TEST_UTIL",
    testonly = True,
    srcs = [
        ":_graphite_srcs",
        "//src/gpu/graphite/compute:compute_srcs",
        "//src/gpu/graphite/geom:geom_srcs",
        "//src/gpu/graphite/render:render_srcs",
        "//src/gpu/graphite/task:task_srcs",
        "//src/gpu/graphite/text:text_srcs",
        "//src/sksl:sksl_graphite_modules_hdrs",
        "//src/sksl:sksl_graphite_modules_srcs",
        "//src/text/gpu:gpu_hdrs",
        "//src/text/gpu:gpu_srcs",
    ],
    hdrs = [
        ":_graphite_hdrs",
        "//include/gpu:shared_gpu_hdrs",
        "//include/gpu/graphite:public_hdrs",
        "//src/gpu/graphite/compute:compute_hdrs",
        "//src/gpu/graphite/geom:geom_hdrs",
        "//src/gpu/graphite/render:render_hdrs",
        "//src/gpu/graphite/task:task_hdrs",
        "//src/gpu/graphite/text:text_hdrs",
    ],
    defines = [
        "SK_GRAPHITE",
        "GPU_TEST_UTILS",
    ],
    visibility = [
        "//dm:__pkg__",
        "//src/gpu/graphite/mtl:__pkg__",
        "//src/gpu/graphite/vk:__pkg__",
        "//tools:__subpackages__",
    ],
    deps = [
        "//:core",
        "//src/base",
        "//src/core:core_priv",
        "//src/gpu",
        "//src/sksl/codegen:gpu",
    ],
)
